<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								用户名称：<input type="text" name="merchantName"/>
							</li>
							 <li>
								用户账号：<input type="text" name="merchantNo"/>
							</li> 
							<li>
								大计划ID：<input type="text" name="planId"/>
							</li>
							<li>
								订单编号：<input type="text" name="orderId"/>
							</li>
							<li>
								小计划状态：<select name="sTATUS" th:with="type=${@dict.getType('plan_item_status')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>创建时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
							<li>
								<a id="btnSearch" class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <!-- <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:hatchetPlanItem:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:hatchetPlanItem:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:hatchetPlanItem:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:hatchetPlanItem:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div> -->
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        //状态数据查询字典表显示
        var sTATUS = [[${@dict.getType('plan_item_status')}]];
        //明细类型 （还款/养卡）
        var tYPE = [[${@dict.getType('plan_item_type')}]];
        var prefix = ctx + "system/hatchetPlanItemForDLS";
        var editFlag = [[${@permission.hasPermi('system:hatchetPlanItem:edit')}]];
        $(function() {
            var options = {
                url: prefix + "/list",
                /* createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export", */
                modalName: "还款计划明细",
				search: false, 
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
				{
		        	field : 'id',
					title : '计划明细ID',
					visible: false
				},
				/* {
					field : 'merchantNo', 
					title : '用户账号',
					sortable: false
				},  */
				{
					field : 'merchantName', 
					title : '用户名称',
					sortable: false
				},
				{
					field : 'planId', 
					title : '大计划ID',
					sortable: false
				},
				
				{
					field : 'fromBankAccount', 
					title : '银行卡号',
					sortable: false
				},
				{
					field : 'fromBankAccountName', 
					title : '持卡人',
					sortable: false
				},
				{
					field : 'orderId', 
					title : '订单号',
					sortable: false
				},
				{
					field : 'fromBankphone', 
					title : '预留手机',
					sortable: false
				},
				{
					field : 'money', 
					title : '付款金额(元)',
					sortable: true
				},
				{
					field : 'tYPE', 
					title : '类型',
					align: 'center',
					formatter: function(value, item, index) {
			            	return $.table.selectDictLabel(tYPE, item.type);
			            }
				},
				
				{
					field : 'sTATUS', 
					title : '状态',
					align: 'center',
					formatter: function(value, item, index) {
			            	return $.table.selectDictLabel(sTATUS, item.status);
			            }
				},
				{
					field : 'acqResponseCode', 
					title : '终端返回码',
					sortable: false
				},
				{
					field : 'planTime', 
					title : '执行时间',
					sortable: true
				},
				{
					field : 'toMoney', 
					title : '到款金额(元)',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'updateTime', 
					title : '修改时间',
					sortable: true
				} ,
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	if(row.status=="10C" || row.status=="70A"){
			            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="laqiPlan(\'' + row.id + '\')"><i class="fa fa-edit"></i>拉起计划</a> ');
		            	}
						return actions.join('');
		            }
		        } ]
            };
            $.table.init(options);
        });
      //拉起单个计划
		function laqiPlan(planItemId){
			if(planItemId.length==0){
				$.modal.alertError("请您输入小计划id");
				return;
			}
           $.ajax({
		        url:ctx + "system/hatchetPlan"+"/laqiPlan", 
		        dataType:"json",
		        type: "POST",
		       	data:"planItemId="+planItemId,
		        success:function(re){
		        	$("#planItemId").val("");
		      		if(re.status=="SUCCESS"){
		      			$.modal.msgSuccess(re.msg);
		      			$("#btnSearch").click();
		      		} else if(re.status=="FAIL"){
		      			$.modal.alertError(re.msg);
		      		}
		        }
		    });
			
		}
    </script>
</body>
</html>